﻿using VIA.Integration.LeadShine;
using VIA.SiMoJi.Domain.Electronics;

namespace VIA.SiMoJi.Domain.Electronics
{
    public partial class Electronic
    {
        /// <summary>
        /// 板卡编号，机台只有一张卡
        /// </summary>
        public static readonly ushort CardId = 0;
        /// <summary>
        /// EtherCAT 端口号，固定为 2
        /// </summary>
        public static readonly ushort Chennel = 2;
        /// <summary>
        /// 扩展模块的节点号,从 1001 开始，按从站数往后累加
        /// </summary>
        public static readonly ushort NodeID = 1001;
        /// <summary>
        /// 撕膜顶升轴和撕膜轴插补坐标系
        /// </summary>
        public static readonly ushort usCoord = 0;




        /// <summary>
        /// 设置所有轴使能On
        /// </summary>
        /// <returns></returns>
        public void SetAllAxisOn() => Controller.ServoOnAll();

        /// <summary>
        /// 设置所有轴使能Off
        /// </summary>
        /// <param name="isEnable"></param>
        /// <returns></returns>
        public void SetAllAxisOff() => Controller.ServoOffAll();

        /// <summary>
        /// 紧急停止所有轴
        /// </summary>
        public void AxisEmergencyStop() => Controller.EmergencyStop();

        /// <summary>
        /// 获取总线状态
        /// </summary>
        /// <returns></returns>
        public bool CheckCardStatus() => Controller.CheckError();

        /// <summary>
        /// 清除总线错误状态
        /// </summary>
        public void ClearCardError() => Controller.ClearError();

        /// <summary>
        /// 所有轴清除错误
        /// </summary>
        public void ClearAllAxisError() => Controller.ClearAllAxisError();
        /// <summary>
        /// 下载参数文件,当使用相对路径时，参数文件与程序必须在同一目录下
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public void DownLoadConfigFile(string filePath) => Controller.LoadConfig(filePath);

        /// <summary>
        /// 设置偏移量的位置值
        /// </summary>
        /// <param name="cardNo"></param>
        /// <param name="axis"></param>
        /// <param name="offset_pos"></param>
        public void SetOffsetPos(ushort cardNo, ushort axis, double offset_pos)
        {
            var intR = Controller.SetOffsetPos(cardNo, axis, offset_pos);
        }
    }
}
